if (obstacle detected )
	stop the RojoBot
else if (black line found) 						// RojoBot is on the black line
	if (turn_flag)                  			// start turn sequence
		compute the next heading				// increment by 1, Right-Turn algorithm
		if (next_heading == inv_heading)		// Skip opposite orientation
			recompute next_heading 
		turn right
		if( current_heading == next_heading)	// stop turn sequence
			clear the turn flag
	else
		if (x OR y co-ordinate is changed)
			compute & store the inv_heading
		move RojoBot forward
else											// RojoBot is off the black line
	store current_heading as old_heading   
	set the turn flag 
	move RojoBot backword(reverse)